/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.exam;

/**
 * <p>Project: javaseapp - Ex8
 * <p>Powered by webrx On 2021-08-08 16:17:32
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Ex9 {
    public static void main(String[] args) {
        //判断字符串中有没有. *  [ ] + ?

        String str = "hello java";
        //(1) indexOf
        if (str.indexOf(".") == -1) {
            System.out.println("没有.");
        } else {
            System.out.println("有.");
        }

        if (str.contains(".")) {
            System.out.println("有.");
        } else {
            System.out.println("没有.");
        }

        //判断是否包含. * + ?
        String p = ".*[\\.\\*\\+\\?\\[\\]\\s]*.*";
        System.out.println(str.matches(p));

        // \w 代表 [a-zA-Z0-9_] \W [^a-zA-Z0-9]
        // \d 代表 [0-9]  \D [^0-9]
        // "1[3,5,8,6]\\d{9}"
        String p2 = "[a-zA-Z][\\w\\.]+@[\\w\\.]+";
        System.out.println("webrx".matches(p2));

        //.*
        String p3 = "[a-zA-Z]{6,12}";
    }
}
